﻿Imports System
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Drawing
Imports System.Workflow.ComponentModel.Compiler
Imports System.Workflow.ComponentModel.Design

Namespace System.Workflow.ComponentModel
    <AlternateFlowActivity, ActivityValidator(GetType(CancellationHandlerValidator)), ToolboxItem(False), Designer(GetType(CancellationHandlerActivityDesigner), GetType(IDesigner)), ToolboxBitmap(GetType(CancellationHandlerActivity), "Resources.CancellationHandler.bmp")> _
    Public NotInheritable Class CancellationHandlerActivity
        Inherits CompositeActivity
        Implements IActivityEventListener([Of] ActivityExecutionStatusChangedEventArgs)
        ' Methods
        Public Sub New()
        End Sub

        Public Sub New(ByVal name As String)
            MyBase.New(name)
        End Sub

        Protected Friend Overrides Function Cancel(ByVal executionContext As ActivityExecutionContext) As ActivityExecutionStatus
            Return SequenceHelper.Cancel(Me, executionContext)
        End Function

        Protected Friend Overrides Function Execute(ByVal executionContext As ActivityExecutionContext) As ActivityExecutionStatus
            Return SequenceHelper.Execute(Me, executionContext)
        End Function

        Protected Friend Overrides Sub Initialize(ByVal provider As IServiceProvider)
            If (MyBase.Parent Is Nothing) Then
                Throw New InvalidOperationException(SR.GetString("Error_MustHaveParent"))
            End If
            MyBase.Initialize(provider)
        End Sub

        Protected Friend Overrides Sub OnActivityChangeRemove(ByVal executionContext As ActivityExecutionContext, ByVal removedActivity As Activity)
            SequenceHelper.OnActivityChangeRemove(Me, executionContext, removedActivity)
        End Sub

        Protected Friend Overrides Sub OnWorkflowChangesCompleted(ByVal executionContext As ActivityExecutionContext)
            SequenceHelper.OnWorkflowChangesCompleted(Me, executionContext)
        End Sub

        Private Sub System.Workflow.ComponentModel.IActivityEventListener<System.Workflow.ComponentModel.ActivityExecutionStatusChangedEventArgs>.OnEvent(ByVal sender As Object, ByVal e As ActivityExecutionStatusChangedEventArgs) Implements IActivityEventListener([Of] ActivityExecutionStatusChangedEventArgs).OnEvent
            SequenceHelper.OnEvent(Me, sender, e)
        End Sub

    End Class
End Namespace

